/*****************************************************************************
 * HUSONG PROPRIETARY INFORMATION
 * <p/>
 * The information contained herein is proprietary to HUSONG
 * and shall not be reproduced or disclosed in whole or in part
 * or used for any design or manufacture
 * without direct written authorization from HUSONG.
 * <p/>
 * Copyright (c) 2015 by HUSONG.  All rights reserved.
 *****************************************************************************/
package com.husong.service;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletRequest;

import com.husong.entity.BatchWithdrawOrder;
import com.husong.entity.Feedback;
import com.husong.entity.Institution;
import com.husong.entity.PayOrder;
import com.husong.entity.RechargeList;
import com.husong.entity.Red;
import com.husong.entity.TrainPic;
import com.husong.entity.TrainTest;
import com.husong.entity.User;
import com.husong.entity.WithdrawOrder;
import com.husong.pojo.AccountBindBean;
import com.husong.pojo.BillBean;
import com.husong.pojo.UserModel;
import com.husong.pojo.UserWalletBean;
import com.husong.pojo.WalletBean;
import com.husong.pojo.WithdrawOrderBean;
import com.husong.pojo.WxPayResult;

/**
 * @author maxmin
 *
 * @date 2015年11月10日 上午11:32:50
 */
public interface UserDataService {
	
	public List<WithdrawOrder> queryAliWithdrawOrderByBatchOrderNo(String batchOrderNo);
	
	public BatchWithdrawOrder queryBatchWithdrawOrderByOrderNo(String batchOrderNo);

    /**
     * 查询所有经纪人数量
     * @return
     */
    Long brokerCount(String cityname);

    /**
     * 用户注册
     * @param telephone 手机号
     * @param code 验证码
     * @return 用户
     */
    User regist(String telephone, String cityname, String code);

    /**
     * 登录
     * @param telephone 手机号码
     * @return 用户 失败则为null
     * @author maxmin
     * @date 2015年11月10日上午11:34:13
     */
    User login(String telephone);

    /**
     * 检查用户是否已经存在
     * @param telephone 手机号码
     * @author maxmin
     * @return false:不存在  true:已经存在
     * @date 2015年11月11日下午15:34:13
     */
    boolean checkUserIsExsit(String telephone);

    /**
     * 根据id获取用户
     * @param id
     * @return
     */
    User get(String id);
    /**
     * 获取培训内容
     * @return
     */
    List<TrainPic> trainPics();
    /**
     * 获取考试题列表
     * @return
     */
    List<TrainTest> trainTests();
    
    /**
	 * 经纪人完成培训
	 * @param brokerid
	 * @return
	 */
    int trained(String brokerid);
	
	/**
	 * 经纪人完成测试
	 * @param brokerid
	 * @return
	 */
	int tested(String brokerid);
	/**
	 * 经纪人认证
	 * @param user
	 * @return
	 */
	int authen(User user);
	
	/**
	 * 获取存在的钱包
	 * @param userId
	 * @return
	 */
	public  UserWalletBean getUserWalletBeanByUserId(String userId);
	
	/**
	 * 获取可用的钱包
	 * @param userId
	 * @return
	 */
	public  UserWalletBean getUsefullUserWalletBeanByUserId(String userId);
	/**
	 * 创建钱包
	 * @param wallet
	 * @return
	 */
	public  int addUserWallet(String user_id);
	
	/**
	 * 设置钱包密码
	 * @param wallet
	 * @return
	 */
	public  int updateWalletPassword(String user_id,String password);
	
	/**
	 * 添加支付宝绑定
	 * @param bean
	 * @return
	 */
	public  int addAccountBind(AccountBindBean bean);
	
	/**
	 * 修改支付宝绑定
	 * @param bean
	 * @return
	 */
	public  int updateAccountBind(AccountBindBean bean);
	
	/**
	 * 通过id获取支付宝绑定
	 * @param id
	 * @return
	 */
	public  AccountBindBean getAccountBind(String id);
	
	/**
	 * 获取用户所有的支付宝绑定
	 * @param user_id
	 * @return
	 */
	public  List<AccountBindBean> getAccountBinds(String user_id);
	
	/**
	 * 修改用户信息
	 * @param user
	 * @return
	 */
	public  int updateUser(UserModel user);
	
	/**
	 * 江湖口号
	 * @param params
	 * @return
	 */
	public  int declare(String user_id,String declaration);
	
	PayOrder addPayOrder(String user_id,String order_id,Integer coupon_type,String coupon_id,Integer pay_type,Integer pay_way);
	
	PayOrder getPayOrderById(String id);
	
	PayOrder getPayOrderByPayOrderNo(String pay_order_no);
	
	List<RechargeList> getRechargeLists();
	
	int addWithdrawOrder(WithdrawOrderBean withdraw);
	
	public List<WalletBean> getBills(String user_id,String lastDateStr,Long lastrowid);
	
	public List<BillBean> getBillsByType(String user_id, String lastDateStr, Long lastrowid,int type);
	
	int addFeedback(Feedback feedback);
	
	BigDecimal getPurchaseSumAmount(String user_id);
	
	BigDecimal getTipSumAmount(String user_id);
	
	BigDecimal getWithdrawSumAmount(String user_id);
	
	public void notifyWeixinUser(WxPayResult wpr);
	
	public String notifyAlipayUser(ServletRequest sr)throws Exception;
	
	int addRed(Red red);
	
	BigDecimal getInviteAmount(String user_id);
	
	int updateUserTag(String user_id,String tag);
	
	List<Institution> getInstitutions();
	
	public List<WithdrawOrder> queryAliWithdrawOrdersByBatchOrderNo(
			String batchOrderNo);
	
    void dealWithSuccessAliBatchWithdrawResult(Map<String,WithdrawOrder> successMap,String batch_no,String notify_id);
    
    void dealWithFailAliBatchWithdrawResult(Map<String,WithdrawOrder> failMap,String batch_no,String notify_id);

}
